﻿<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>
<body>
    
<div id="app" v-cloak>   
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini">
            <el-row>
                <el-col :xs="24" :sm="12" :md="4" :lg="3" :xl="1">
                    <el-form-item :label="user.loginName+mark.m" prop="loginName">
                        <el-input type="text" v-model="Form.loginName" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="8" :lg="9" :xl="11">
                    <el-form-item :label="user.name+mark.m" prop="name">
                        <el-input type="text" v-model="Form.name" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="8" :lg="9" :xl="11">
                    <el-form-item :label="user.loginName+mark.m" prop="loginName">
                        <el-input type="text" v-model="Form.loginName" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="12" :md="4" :lg="3" :xl="1">
                    <el-form-item :label="user.name+mark.m" prop="name">
                        <el-input type="text" v-model="Form.name" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="1">
                    <el-form-item :label="user.sex+mark.m" prop="sex">
                        <el-select @visible-change="visibleChange" v-model="Form.sex" :placeholder="user.sex">
                            <el-option v-for="item in sex" :label="item.value" :value="item.key"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="6" :md="8" :lg="9" :xl="11">
                    <el-form-item :label="user.password+mark.m" prop="password">
                        <el-input type="password" v-model="Form.password" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="6" :md="8" :lg="9" :xl="11">
                    <el-form-item :label="user.sex+mark.m" prop="sex">
                        <el-select @visible-change="visibleChange" v-model="Form.sex" :placeholder="user.sex">
                            <el-option v-for="item in sex" :label="item.value" :value="item.key"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :xs="24" :sm="6" :md="4" :lg="3" :xl="1">
                    <el-form-item :label="user.password+mark.m" prop="password">
                        <el-input type="password" v-model="Form.password" autocomplete="off"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item :label="user.remarks+mark.m" prop="remarks">
                <el-input type="textarea" v-model="Form.remarks" autocomplete="off"></el-input>
            </el-form-item>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnConfirm}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
   
    </div>
    <script type="text/javascript">
      
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                //获取下拉菜单sex
                sex: [],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    loginName: '',
                    name: '',
                    password: '',
                    sex: '',
                    remarks: '',
            
                },
                //表单验证
                rules: {
                    loginName: [
                        verification.NotNull,
                        { pattern: verification.StringLengthAtoB.t.format(2, 10), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }   
                    ],
                    password: [
                        verification.NotNull
                        
                    ],
                    sex: [
                        verification.NotNullSelect
                    ],
                    name: [
                        verification.NotNull
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            
                            onSubmitForm(this, '/api/User/Save', mythis.Form);
                        } else {
                            //验证失败

                            return false;
                        }
                    });
                   
                },
                
                getData: function () {
                   

                    getData(this, '/api/User/get?id=' + this.id);
                    this.Form.sex = this.Form.sex + "";
                }
            },
            mounted: function () {
                this.id = getUrlParam("id");
                this.getData();
                //获取下拉菜单内容
                this.sex = getDicData('01');
            }
        });
    </script>
</body>
</html>